package com.ruoyi.back.v1

import com.ruoyi.app.common.Data
import com.ruoyi.app.common.Ok
import com.ruoyi.app.common.PageData
import com.ruoyi.back.v2.domain.*
import com.ruoyi.back.v2.service.SpreadManagerBackService
import com.ruoyi.back.v2.service.SpreadSettingService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/system/spreadManager")
@Api(tags = ["推广管理相关接口"])
class SpreadManager {

    @Autowired
    private lateinit var spreadManagerBackService: SpreadManagerBackService

    @Autowired
    private lateinit var spreadSettingService: SpreadSettingService

    @ApiOperation("获取推广注册用户新增趋势")
    @GetMapping("spreadStatistics")
    fun spreadStatistics(spreadStatisticsSearchParam: SpreadStatisticsSearchParam): Data<SpreadStatistics> =
        spreadManagerBackService.spreadStatistics(spreadStatisticsSearchParam)

    @ApiOperation("获取推广注册用户")
    @GetMapping("spreadRegisterUser")
    fun spreadRegisterUser(spreadStatisticsSearchParam: SpreadStatisticsSearchParam): PageData<SpreadRegisterUser> =
        spreadManagerBackService.spreadRegisterUser(spreadStatisticsSearchParam)

    @ApiOperation("获取推广信息")
    @GetMapping("spreadUserInfo")
    fun spreadUserInfo(spreadUserInfoSearchParam: SpreadUserInfoSearchParam): PageData<SpreadUserInfo> =
        spreadManagerBackService.spreadUserInfo(spreadUserInfoSearchParam)

    @ApiOperation("推广信息查看")
    @GetMapping("spreadUserLevelInfo")
    fun spreadUserLevelInfo(spreadUserInfoSearchParam: SpreadUserInfoSearchParam): PageData<SpreadUserLevelInfo> =
        spreadManagerBackService.spreadUserLevelInfo(spreadUserInfoSearchParam)

    @ApiOperation("提现记录")
    @GetMapping("withdrawRecord")
    fun withdrawRecord(userId: Long): PageData<WithdrawRecord> = spreadManagerBackService.withdrawRecord(userId)

    @ApiOperation("提现审核")
    @PostMapping("withdrawCheck")
    fun withdrawCheck(@RequestBody withDrawCheck: WithDrawCheck): Data<Boolean> = spreadManagerBackService.withdrawCheck(withDrawCheck)


    @ApiOperation("推广设置保存修改")
    @PostMapping("spreadSettingSave")
    fun spreadSettingSave(@RequestBody spreadSetting: SpreadSetting): Data<Boolean> = Ok("操作成功", spreadSettingService.saveSpreadSetting(spreadSetting))

    @ApiOperation("获取推广设置")
    @GetMapping("getSpreadSetting")
    fun getSpreadSetting(): Data<SpreadSetting> = Ok("获取成功", spreadSettingService.getSpreadSetting())

    @ApiOperation("修改用户收益余额")
    @PostMapping("updateUserEmployeeMoney")
    fun updateUserEmployeeMoney(@RequestBody updateEmployeeMoney: UpdateEmployeeMoney): Data<Boolean> = spreadManagerBackService.updateUserEmployeeMoney(updateEmployeeMoney)
}